//
//  AddressCell.m
//  cityStar
//
//  Created by joyban on 14-12-26.
//  Copyright (c) 2014年 tiny. All rights reserved.
//

#import "AddressCell.h"
#import "UIColor+FlatUI.h"
#import "HttpRequestManager.h"
#import "KInterFace.h"
#import "MerchantDetail.h"

@implementation AddressCell

+(CGFloat)heightOfTableCell
{
    return 145;
}

- (void)awakeFromNib {
    self.Contactbtn.layer.borderWidth = 0.5;
    self.Contactbtn.layer.cornerRadius = 4.0;
    self.Contactbtn.layer.borderColor = [[UIColor colorFromHexCode:@"CCCCCC"] CGColor];
    
    self.intoBtn.layer.borderWidth = 0.5;
    self.intoBtn.layer.cornerRadius = 4.0;
    self.intoBtn.layer.borderColor = [[UIColor colorFromHexCode:@"CCCCCC"] CGColor];
}

-(void)configWithAddressID:(NSString *)addressID
{
    self.addressID = addressID;
    NSString *postUrl = [NSString stringWithFormat:@"%@/%@",KInterface_GetSupplier,addressID];
    [HttpRequestManager getMethod:postUrl parameters:nil completedMainBlock:^(BOOL success, id response, NSString *errMsg) {
        if (success) {
            self.merchant = [MerchantDetail objectFromDictionary:response[@"value"]];
            self.labelMerchantName.text = self.merchant.name;
            if (self.merchant.telphone) {
                self.labelTelNum.text = self.merchant.telphone;
            }else if(self.merchant.service_mobile){
                self.labelTelNum.text = self.merchant.service_mobile;
            }else{
                self.labelTelNum.text = self.merchant.mobile;
            }
            self.labelAddress.text = self.merchant.address;
        }
    }];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (IBAction)Contact_Action:(UIButton *)sender {
    [self.delegate senderContactClick:self.labelTelNum.text];
}

- (IBAction)into_Action:(UIButton *)sender {
    [self.delegate senderintoactClick:self.addressID];

}
@end
